/*
 * (C) 2012 Sheng Yi
 * Calculate the score
 */
#include <stdio.h>

int cal_score(int score[], int judge_type[], int n);

int main()
{
	int score[5] = {4, 3, 8, 9, 7};
	int judge_type[5] = {1, 2, 1, 2, 2};
	printf("final score is %d\n", cal_score(score, judge_type, 5));
	return 0;
}

int cal_score(int score[], int judge_type[], int n)
{
	int i;
	int expert_score = 0, expert_num = 0;
	int public_score = 0, public_num = 0;
	for (i = 0; i < n; i++)
	{
		if (judge_type[i] == 1) // export
		{
			expert_score += score[i];
			expert_num++;
		}
		else if (judge_type[i] == 2) // public
		{
			public_score += score[i];
			public_num++;
		}
		else
			; // other, just ignore
	}

	// calculate average score
	if (public_num > 0)
		public_score /= public_num;

	if (expert_num > 0)
		expert_score /= expert_num;
	int average = expert_score * 0.6 + public_score * 0.4;
	return average;
}
